/*
 * Copyright 2023-2025 Dozingfiretruck
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "nes.h"
#include "huodouluo.h"
#include "zhadanren.h"

int add_main(void)
{
    nes_t* nes = nes_init();
    if (nes == NULL) {
        NES_LOG_ERROR("Failed to initialize NES\n");
        return -1;
    }

    NES_LOG_INFO("Loading NES ROM from binary array\n");
    int ret = nes_load_rom(nes, _mario);
    if (ret != 0) {
        NES_LOG_ERROR("nes load ROM fail\n");
        goto error;
    }
    nes_run(nes);
    nes_unload_rom(nes);
    nes_deinit(nes);
    return 0;

error:
    nes_deinit(nes);
    return -1;
}

